<template>
  <view class="list_wrap">
    <u-list @scrolltolower="handleScrolltolower">
      <u-list-item
        v-for="(item ,index) in itemList"
        :key="index"
      >
        <view class="cell_wrap" @click="handleClickCell(item)">
          <view class="cell_left">
            <view class="title_wrap">
              <view class="cell_label">{{ item.invoiceTitle }}</view>
              <text
                v-if="item.isDefault"
                class="default_icon t-icon t-icon-moren_tongyong_1"
              />
            </view>
            <view class="detail_wrap">{{ getShowInvoiceType(item) }}</view>
          </view>
          <view class="cell_right">
            <text class="right_icon font_family icon-a-arrowright_tongyong_2" />
          </view>
        </view>
      </u-list-item>
    </u-list>
  </view>
</template>
<script>
export default {
  props: {
    list: {
      type: Array,
      default: () => []
    }
  },
  computed: {
    itemList() {
      return [...this.list]
    }
  },
  methods: {
    handleScrolltolower() {
      this.$emit('scrolltolower')
    },
    handleClickCell(item) {
      this.$emit('select-item', item)
    },
    // 获取展示的发票类型
    getShowInvoiceType(item) {
      const isCertify = this.vuex_memberCompanyInfo?.examStatus == 20 // 认证会员
      if (isCertify && item.invoiceType == 0) return '专票抬头'
      if (isCertify && item.invoiceType == 1) return '普票抬头'
      if (!isCertify && !item.taxId) return '个人'
      if (!isCertify && item.taxId) return '企业'
      return ''
    }
  }
}
</script>
<style lang="scss" scoped>
.list_wrap {
  margin-top: 26rpx;
  padding: 0 32rpx;
  .cell_wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 130rpx;
    margin-bottom: 16rpx;
    border-radius: 8rpx;
    background-color: $uni-bg-color;
    .cell_left {
      display: flex;
      flex-direction: column;
      margin-left: 24rpx;
      .title_wrap {
        display: flex;
        align-items: center;
        .cell_label {
          font-size: 28rpx;
          color: $uni-text-color;
        }
        .default_icon {
          width: 56rpx;
          height: 32rpx;
          margin-left: 8rpx;
        }
      }
      .detail_wrap {
        margin-top: 8rpx;
        color: #808080;
      }
    }
    .cell_right {
      height: 130rpx;
      line-height: 130rpx;
      margin-right: 24rpx;
      .right_icon {
        font-size:$uni-font-size-lg;
        color: $uni-text-color;
      }
    }
  }
}
</style>
